/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.io.File;

/**
 * <p>Project: app2022 - Ex1
 * <p>Powered by webrx On 2022-01-17 15:45:22
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Ex1 {
    public static int sum = 0;

    public static void main(String[] args) {
        var d = new File(System.getProperty("user.dir"));
        count(d);
        System.out.println(sum);
    }

    public static void count(String dir) {
        count(new File(dir));
    }

    /**
     * Description: 统计指定的目录下，有多少个java文件
     *
     * @date: 2022/1/17 15:49
     * @params: [java.io.File]
     * @return: void
     */
    public static void count(File dir) {
        for (File t : dir.listFiles()) {
            if (t.isDirectory()) {
                count(t);
            } else if (t.getName().toLowerCase().endsWith(".java")) {
                ++sum;
            }
        }
    }
}
